import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/modules/preferences/view/preferences_add_item.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_button.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_card.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'logic.dart';

class PreferencesAddPage extends StatefulWidget {
  const PreferencesAddPage({Key? key}) : super(key: key);

  @override
  State<PreferencesAddPage> createState() => _PreferencesAddPageState();
}

class _PreferencesAddPageState extends State<PreferencesAddPage> {
  final PreferencesAddLogic logic = Get.put(PreferencesAddLogic());
  final FocusNode _phoneNode = FocusNode();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: HLAppBar(navigationTitle: "收件人偏好设置"),
        body: MGCard(
          nodeList: [_phoneNode],
          padding: EdgeInsets.all(12),
          margin: EdgeInsets.all(12),
          children: [
            PreferencesAddItem(
              controller: logic.phone,
              title: "手机号",
              hintText: "请输入手机号码",
              enable: true,
              focusNode: _phoneNode,
            ),
            SizedBox(height: 20),
            GetBuilder<PreferencesAddLogic>(builder: (controller) {
              return PreferencesAddItem(
                controller: controller.preference,
                title: "选择偏好设置",
                hintText: "请选择偏好设置",
                enable: false,
                showTrailing: true,
                action: () {
                  controller.sheetBottom();
                },
              );
            }),
            Container(
              padding: EdgeInsets.only(top: 20),
              child: Text(
                "温馨提示: 备注信息将回在您的柜前，派对应手机号的包裹时弹框展示，请悉知。",
                style: TextStyle(
                  fontSize: MGFont.textFont2,
                  color: MGColors.redColor,
                ),
              ),
            )
          ],
        ),
        bottomNavigationBar: MGButton(
          title: "确认",
          padding: EdgeInsets.only(left: 30, right: 30, bottom: 30, top: 15),
          buttonAction: () {
            logic.sureAction();
          },
        ));
  }

  @override
  void dispose() {
    Get.delete<PreferencesAddLogic>();
    super.dispose();
  }
}
